#include<deque>
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXN=1e5+10;
struct plane{
	int get,leave;
} l1[MAXN],l2[MAXN];
bool cmp(plane a,plane b){
	return a.get<b.get;
}
deque<plane> d,p;
int n,m1,m2,ans,out;
int main(){
	freopen("airport1.in","r",stdin);
	freopen("airport.out","w",stdout);
	scanf("%d%d%d",&n,&m1,&m2);
	if (n>=m1+m2){
		printf("%d",m1+m2);
		return 0;
	}
	for (int i=1;i<=m1;i++) scanf("%d%d",&l1[i].get,&l1[i].leave);
	for (int i=1;i<=m2;i++) scanf("%d%d",&l2[i].get,&l2[i].leave);
	sort(l1+1,l1+m1+1,cmp);
	sort(l2+1,l2+m2+1,cmp);
	for (int i=0;i<=n;i++){
		int cnt=0,n1=0,n2=0,pid=0;//plane in deque
		if (i){
			while (m1>n1){
				n1++;
				while (!d.empty()&&d.back().leave<l1[n1].get){
					d.pop_back();
					pid--;
				}
				if (d.empty()){
					while (!p.empty()&&p.back().leave<l1[n1].get){
						p.pop_back();
						pid--;
					}
				}
				if (pid<i){
					while (!d.empty()&&l1[n1].leave<d.front().leave){
						p.push_back(d.front());
						d.pop_front();
					}
					while(!p.empty()&&l1[n1].leave>p.back().leave){
						d.push_front(p.back());
						p.pop_back();
					}
					d.push_front(l1[n1]);
					pid++;
					cnt++;
				}
			}
			pid=0;
			while(!d.empty()) d.pop_back();
			while(!p.empty()) p.pop_back();
		}
		if (n-i){
			while (m2>n2){
				n2++;
				while (!d.empty()&&d.back().leave<l2[n2].get){
					d.pop_back();
					pid--;
				}
				if (d.empty()){
					while (!p.empty()&&p.back().leave<l2[n2].get){
						p.pop_back();
						pid--;
					}
				}
				if (pid<(n-i)){
					while (!d.empty()&&l2[n2].leave<d.front().leave){
						p.push_back(d.front());
						d.pop_front();
					}
					while(!p.empty()&&l2[n2].leave>p.back().leave){
						d.push_front(p.back());
						p.pop_back();
					}
					d.push_front(l2[n2]);
					pid++;
					cnt++;
				}
			}
			while(!d.empty()) d.pop_back();
			while(!p.empty()) p.pop_back();
		}
		if (cnt>ans) ans=cnt;
	}
	printf("%d",ans);
	fclose(stdin);
	fclose(stdout);
	return 0;
}
